package com.trainoo.job;

import com.trainoo.repository.ChapterRepository;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by zhoutao on 2018/7/4 11:35
 */
@Component
public class NovelUpdateCrawlerJob {

    private static Logger LOG = LoggerFactory.getLogger(NovelUpdateCrawlerJob.class);
    private static String URL = "http://www.6mao.com/html/53/53302/index.html";

    @Autowired
    private ChapterRepository repository;

    public void start() {
        try{
            //获取列表信息
            Document document = Jsoup.connect(URL).get();
            Elements lieBiaoList = document.getElementsByClass("liebiao_bottom").first()
                    .getElementsByTag("dl").first()
                    .getElementsByTag("dd");

        } catch (Exception e){
            LOG.error("【抓取更新信息】出现异常：{}", e);
        }
    }

    //@Scheduled(cron = "0 * * * * ?")
    public void run(){
        LOG.error("【抓取更新信息】=======开始======");
        start();
        LOG.error("【抓取更新信息】=======结束======");
    }
}
